package com.lqian.array;

import java.util.Iterator;
import java.util.List;

/**
 * 迭代器不停的遍历集合中的元素
 */
public class ThreadIterator extends Thread{
    private List list;

    public ThreadIterator(List list) {
        this.list = list;
    }

    @Override
    public void run() {
        while (true){
            for (Iterator iteratorTemp= list.iterator();iteratorTemp.hasNext();) {
                iteratorTemp.next();
                try {
                    Thread.sleep(5);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }

            }
        }
    }
}
